#include "ReadFile.h"

ReadFile::ReadFile()
{}

void haffman::read(QString s) // 读入
{
  FILE *tem;
  int   tem1 = 0;
  strcpy(first_name, s.toLocal8Bit().data()); // 转换字符串
  tem = fopen(first_name, "rb");
  if (tem == NULL)
  {
    return;
  }
  strcpy(code_name,        first_name);
  while (code_name[tem1] != '.' && code_name[tem1]) ++tem1;
  strcpy(code_name + tem1, ".cod");

  char *tem2 = r;
  tem1  = 0;
  lenth = 0;
  do
  {
    tem1   = fread(tem2, sizeof(char), 1024, tem);
    lenth += tem1;
    if (lenth > 10 * 1024 * 1024) // 1m=1024kb 1kb=1024b
    {
      lenth = 10 * 1024 * 1024;
      break;
    }
    tem2 += tem1;
  } while (tem1 == 1024);
  fclose(tem);
  QFile tem3(first_name);
  origin_size = tem3.size();
}
